package com.capgemini.cn.authority.data.repository;

import com.capgemini.cn.authority.data.entity.Groups;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created at 2017/8/21
 *
 * @author Andriy
 */
@Repository
public interface GroupsRepository extends JpaRepository<Groups, Long> {

    /**
     * 排序查询所有根级用户组
     *
     * @param sort 排序对象
     */
    List<Groups> findAllByParentGroupIsNull(Sort sort);

    /**
     * 分页查询所有根级用户组
     *
     * @param pageable 分页对象
     */
    Page<Groups> findAllByParentGroupIsNull(Pageable pageable);

    /**
     * 根据业务数据标识查询用户组对象
     *
     * @param bizIdentity 业务数据标识
     */
    Groups findByBizIdentityEquals(String bizIdentity);
}
